import os

def get_detection_data_path():
    """获取detection_data目录的绝对路径"""
    current_dir = os.path.dirname(os.path.abspath(__file__))
    return os.path.join(current_dir, '..', 'data', 'detection_data')

def get_rootheal_data_path():
    """获取rootheal_data目录的绝对路径"""
    current_dir = os.path.dirname(os.path.abspath(__file__))
    return os.path.join(current_dir, '..', 'data', 'rootheal_data')


def read_file_content(file_path):
    """读取文件内容，支持多种编码"""
    encodings = ['utf-8', 'gbk', 'gb2312', 'latin-1']
    
    for encoding in encodings:
        try:
            with open(file_path, 'r', encoding=encoding) as file:
                return file.read()
        except UnicodeDecodeError:
            continue
    
    # 如果所有编码都失败，以二进制模式读取
    with open(file_path, 'rb') as file:
        return file.read().decode('utf-8', errors='ignore')